package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import net.bytebuddy.asm.Advice;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface SetMealMapper {
    @AutoFill(OperationType.INSERT)
    void insert(Setmeal setmeal);

    Page<SetmealVO> getPage(SetmealPageQueryDTO setmealPageQueryDTO);

    void batchDeleteMeal(Long[] batchId);

    @Select("select s.* ,c.name as categoryName from setmeal s left join category c on s.category_id = c.id where s.id = #{id}")
    SetmealVO getSetMealById(Long id);

    @AutoFill(OperationType.UPDATE)
    void updateSetMeal(Setmeal setmeal);

    @Select("select * from setmeal where category_id = #{categoryId} and status = 1")
    List<Setmeal> getList(Long categoryId);

    @Select("select count(id) from setmeal where status = #{status}")
    Integer getSetmealOverview(Integer status);
}
